<template>
	<view class="container bg-white">
		<cu-custom :title="$t('index.securityCenter')" bgColor="bg-white" :isBack="false">
			<block v-slot:backText>{{ $t('index.securityCenter') }}</block>
		</cu-custom>
		<view class="padding-lr">
			<view style="position: relative;height: 591px;" class="bg-img banner-image  flex align-end margin-top">
				<image style="width: 100%;height: 100%;" src="../../static/home/bg_banner.png"></image>
				<view style="position: absolute;bottom: 0;" class=" padding padding-top-xl flex-sub margin-bottom">
					<view v-if="setting.platform!='android'" class="banner-title">
						{{ $t('index.downIOSHint') }}
					</view>
					<view v-else class="banner-title">
						{{ $t('index.downHint') }}
					</view>
					<view v-if="setting.platform=='android'">
						<button @click="handleNavigate('/pages/message/serverchat',1)"
							class="cu-btn flex-sub bg-menu  round margin-lr-sm">{{ $t('index.downAssistant') }}</button>
					</view>
					<view v-if="setting.platform!='android'" class="banner-desc">
						{{ $t('index.riskIOSHint') }}
					</view>
					<view v-else class="banner-desc">
						{{ $t('index.riskHint') }}
					</view>
				</view>
			</view>
			<view class="section-header">
				<view class="title"> {{ $t('index.themeHot') }}</view>
			</view>
			<view class="section-2 bg-white margin-top">
				<view class="item"
					@click="handleWebView('https://faq.whatsapp.com/497209988909970/?helpref=popular_topics')"
					hover-class="none">
					<view>
						<image class="item-image" src="/static/home/icon_start.png" mode="widthFix"></image>
					</view>

					<view class="title">{{ $t('index.start') }}</view>
					<view class="tips"></view>
				</view>
				<view class="item"
					@click="handleWebView('https://faq.whatsapp.com/898107234497196/?helpref=popular_topics')"
					hover-class="none">
					<view>
						<image class="item-image" src="/static/home/icon_aq.png" mode="widthFix"></image>
					</view>

					<view class="title">{{ $t('index.entrench') }}</view>
					<view class="tips"></view>
				</view>
			</view>
			<view class="section-2 bg-white margin-top">
				<view class="item"
					@click="handleWebView('https://faq.whatsapp.com/1144861179456352/?helpref=popular_topics')"
					hover-class="none">
					<view>
						<image class="item-image" src="/static/home/icon_backups.png" mode="widthFix"></image>
					</view>

					<view class="title">{{ $t('index.backups') }}</view>
					<view class="tips">{{ $t('index.backups2') }}</view>
				</view>
				<view class="item"
					@click="handleWebView('https://faq.whatsapp.com/773166357950949/?helpref=popular_topics')"
					hover-class="none">
					<view>
						<image class="item-image" src="/static/home/icon_information.png" mode="widthFix"></image>
					</view>

					<view class="title">{{ $t('index.infomation') }}</view>
					<view class="tips"></view>
				</view>
			</view>
			<view class="section-2 bg-white margin-top">
				<view class="item"
					@click="handleWebView('https://faq.whatsapp.com/768544097924262/?helpref=popular_topics')"
					hover-class="none">
					<view>
						<image class="item-image" src="/static/home/icon_group.png" mode="widthFix"></image>
					</view>

					<view class="title">{{ $t('index.groups') }}</view>
					<view class="tips"></view>
				</view>
				<view class="item"
					@click="handleWebView('https://faq.whatsapp.com/825930685527017/?helpref=popular_topics')"
					hover-class="none">
					<view>
						<image class="item-image" src="/static/home/icon_shopping.png" mode="widthFix"></image>
					</view>

					<view class="title">{{ $t('index.business') }}</view>
					<view class="tips"></view>
				</view>
			</view>
		</view>
		<view>
			<view class="footer-desc-item">
				<view class="title">{{ $t('index.employ') }}</view>
				<view class="content">
					<view class="cell" @click="handleNavigate('/pages/canteen/index',1)">
						{{ $t('index.function') }}
					</view>
					<view class="cell" @click="handleNavigate('/pages/canteen/index',1)">
						{{ $t('index.down') }}
					</view>
				</view>
			</view>
			<view class="footer-desc-item">
				<view class="title">{{ $t('index.aboutUS') }}</view>
				<view class="content">
					<view class="cell" @click="handleNavigate('/pages/canteen/index',1)">
						{{ $t('index.business') }}
					</view>
					<view class="cell" @click="handleNavigate('/pages/canteen/index',1)">
						{{ $t('index.safety') }}
					</view>
					<view class="cell" @click="handleNavigate('/pages/canteen/index',1)">
						{{ $t('index.privacy') }}
					</view>
				</view>
			</view>
			<view class="footer-desc-item">
				<view class="title">{{ $t('index.callme') }}</view>
				<view class="content">
					<view class="cell" @click="handleNavigate('/pages/canteen/index',1)">
						{{ $t('index.callme') }}
					</view>
					<view class="cell" @click="handleNavigate('/pages/canteen/index',1)">
						{{ $t('index.facebook') }}
					</view>
					<view class="cell" @click="handleNavigate('/pages/canteen/index',1)">
						{{ $t('index.twitter') }}
					</view>
				</view>
			</view>
			<view class="footer-desc-item flex justify-between align-center">
				<view>
					<image style="width: 119px;height: 16px;" src="../../static/home/icon_footer.png"></image>
				</view>
				<view class="title"> © 2024 WhatsApp</view>
			</view>
		</view>
		<!-- <nomore text="已经到底了,去其他页面逛逛吧" visible></nomore> -->

		<view class="footer-menu" style="bottom: 10px;background: none;">
			<view class="padding-xs flex justify-center">
				<button style="height:3.5rem;border-radius:1.75rem;font-size:1.5rem" @click="handleNavigate('/pages/message/serverchat',1)"
					class="cu-btn flex-sub bg-menu lg round">{{ $t('index.detection') }}</button>
			</view>
		</view>
	</view>
</template>

<script setup lang="ts">
	import cuCustom from '@/components/cu-custom-tabar.vue';
	import nomore from '@/components/nomore/nomore.vue';
	import { ref } from 'vue';
	import { onShow, onLoad, onPullDownRefresh, onReachBottom, onShareAppMessage } from '@dcloudio/uni-app';
	import { useSettingStore } from '@/stores/index';
	const setting = useSettingStore();
	onShareAppMessage((res) => {
		if (res.from === 'button') {// 来自页面内分享按钮
			console.log(res.target)
		}
		const pages = getCurrentPages();
		const page : any = pages[pages.length - 1];
		const path = page.$page.fullPath;
		return {
			withShareTicket: false,
			title: '邀请您体验小程序',
			content: '源社区,你的社区生活管家',
			imageUrl: '',
			path: path + '?inviteUserId=' + setting.userInfo.id,
			success: (res : any) => {

			},
			fail: (res : any) => {

			},
			complete: (res : any) => {

			}
		}
	})

	const handleNavigate = (url : string, type : number) => {
		uni.navigateTo({
			url: url
		})
	}
	const handleWebView = (url : any) => {
		// uni.navigateTo({
		// 	url: '/pages/index/webview?url=' + encodeURIComponent(url)
		// });
		window.open(url, '_blank')
	};
	onReachBottom(() => {

	});
	onPullDownRefresh(() => {

	});
	onLoad(() => {
		const browserLanguage = navigator.languages[0];
		console.log(browserLanguage);
		// 以下情况认为是英文
		if (browserLanguage == 'en_hk' || browserLanguage == 'en_us' || browserLanguage == 'en_gb') {
			uni.setLocale('en')
		}else if (browserLanguage == 'zh_tw' || browserLanguage == 'zh_hk') {
			uni.setLocale('hk')
		}else if (browserLanguage == 'es_es' || browserLanguage == 'es_mx' || browserLanguage == 'es_ar') {
			uni.setLocale('es')
		}else if (browserLanguage == 'khm' || browserLanguage == 'km') {
			uni.setLocale('km')
		}else if (browserLanguage == 'zh-CN') {
			uni.setLocale('zh')
		}else{
			uni.setLocale(browserLanguage)
		}
		//
	})
</script>

<style lang="scss" scoped>
	page {
		max-height: 100%;
	}

	.banner-image {
		background-image: url(@/static/home/bg_banner.png);
		height: 70vh;
	}

	.footer-desc-item {
		background: #F0F2F5;
		padding: 30upx;

		.title {
			font-family: PingFangSC, PingFang SC;
			font-weight: 400;
			font-size: 0.85rem;
			color: #818181;
			line-height: 2.2rem;
			text-align: left;
			font-style: normal;
		}

		.content .cell {
			font-family: PingFangSC, PingFang SC;
			font-weight: 800;
			font-size: 1rem;
			color: #000000;
			line-height: 2.2rem;
			text-align: left;
			font-style: normal;
		}
	}

	.bg-img {
		width: 100%;
		height: 70vh;
		background: #D8D8D8;
		border-radius: 1rem;
		border: 1px solid #979797;

		.banner-title {
			font-family: PingFangSC, PingFang SC;
			font-weight: 400;
			font-size: 3rem;
			color: #FFFFFF;
			line-height: 3.5rem;
			text-align: left;
			font-style: normal;
			padding-top: 2rem;
			padding-bottom: 2rem;
		}

		.banner-desc {
			font-family: PingFangSC, PingFang SC;
			font-weight: 400;
			font-size: 1rem;
			color: #FFFFFF;
			line-height: 1.5rem;
			text-align: left;
			font-style: normal;
			padding-top: 2rem;
			padding-bottom: 2rem;
		}
	}

	.page-header {
		position: relative;

		.shop {
			position: absolute;
			left: 2rem;
			top: 2rem;
		}
	}

	.banner-swiper {
		width: 100%;
		height: 550rpx;

		.banner-swiper-item {
			image {
				width: 100%;
			}
		}
	}

	.page-content {
		width: 100%;
		padding: 0 30rpx;
		position: relative;
	}

	.section-1 {
		position: relative;
		background-color: $bg-color-white;
		margin-top: 20rpx;
		border-radius: $border-radius-lg;
		padding: 60rpx 0;
		display: flex;
		margin-bottom: 30rpx;
		box-shadow: 0px 2px 4px 0px rgba(200, 200, 200, 0.5), 0px 2px 4px 0px rgba(200, 200, 200, 0.5);
		border-radius: 8px;

		.item {
			flex: 1;
			flex-shrink: 0;
			display: flex;
			flex-direction: column;
			align-items: center;
			position: relative;

			&:nth-child(1):after {
				content: '';
				position: absolute;
				right: 0;
				top: 0;
				bottom: 0;
				width: 2rpx;
				background-color: $border-color;
			}

			image {
				width: 100rpx;
				margin-bottom: 20rpx;
			}

			.wenyue-font {
				font-size: 48rpx;
				margin-bottom: 10rpx;
			}
		}
	}

	.section-tags {
		border-radius: $border-radius-lg;
		background: #ffffff;
		box-shadow: 0px 2px 4px 0px rgba(200, 200, 200, 0.5);
	}

	.section-msg {
		background: #ffffff;
		box-shadow: 2px 2px 4px 2px rgba(200, 200, 200, 0.5);
		border-radius: 30px;
	}

	.section-2 {
		display: flex;
		justify-content: space-between;
		margin-bottom: 30rpx;

		.item {
			width: 335rpx;
			display: flex;
			flex-direction: column;
			align-items: left;
			justify-content: left;
			background: #FFFFFF;
			box-shadow: 0px 2px 7px 0px rgba(170, 170, 170, 0.5);
			border-radius: 20px;
			border: 2px solid #E1E1E1;
			padding: 20upx;

			.item-image {
				width: 90rpx;
				height: 90rpx;
			}

			.title {
				font-family: PingFangSC, PingFang SC;
				font-weight: 700;
				font-size: 1rem;
				color: #000000;
				line-height: 1.5rem;
				text-align: left;
				font-style: normal;
				margin-top: 2rem;
			}

			.tips {
				font-family: PingFangSC, PingFang SC;
				font-weight: 700;
				font-size: 1rem;
				color: #000000;
				line-height: 1.5rem;
				text-align: left;
				font-style: normal;
			}
		}
	}

	.section-3 {
		margin-bottom: 30rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;
		font-size: $font-size-base;
		color: $text-color-assist;
		padding: 0 10rpx;

		.my-integral {
			flex: 1;
			display: flex;
			flex-direction: column;

			.integrals {
				display: flex;
				align-items: center;
				font-size: $font-size-lg;
				color: $text-color-base;
				margin-bottom: 10rpx;

				.neutra-font {
					margin-left: 10rpx;
					font-size: 42rpx;
				}
			}
		}
	}

	.content-section {
		background-color: #ffffff;
		padding: 0 30rpx;
	}

	.section-header {
		display: flex;
		align-items: baseline;
		padding: 10rpx 20rpx;

		.title {
			margin-right: 20rpx;
			font-family: PingFangSC, PingFang SC;
			font-weight: 900;
			font-size: 40rpx;
			color: #000000;
			line-height: 56px;
			text-align: left;
			font-style: normal;
		}

		.subtitle {
			font-family: 'neutra';
			font-size: $font-size-sm;
			color: $text-color-assist;
		}
	}

	.bg-menu {
		background: #24D366;
		border-radius: 20px;
		box-shadow: 2px 2px 5px 0px rgba(0, 255, 0, 0.5);
	}
</style>